﻿using Collections_Join;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace Collections_Join
{
    
    
    /// <summary>
    ///This is a test class for CollectionsJoinTest and is intended
    ///to contain all CollectionsJoinTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CollectionsJoinTest
    {

        public void JoinTestHelper<T>()
        {
            List<int> collection = new List<int>();
            collection.Add(5);
            collection.Add(3);
            collection.Add(-1);

            string expected = "[5, 3, -1]"; 
            string actual = collection.MyJoin();
            
            Assert.AreEqual(expected, actual);
        }


        [TestMethod()]
        public void JoinTest()
        {
            JoinTestHelper<GenericParameterHelper>();
        }

        [TestMethod()]
        public void JoinTestWithNullInFront()
        {
            JoinTestHelperWithNullInFront<GenericParameterHelper>();
        }

        public void JoinTestHelperWithNullInFront<T>()
        {
            List<string> collection = new List<string>();
            collection.Add(null);
            collection.Add("pesho");
            collection.Add("rofl");

            string expected = "[pesho, rofl]";
            string actual = collection.MyJoin();

            Assert.AreEqual(expected, actual);
        }


        [TestMethod()]
        public void JoinTestWithNullInAtTheEnd()
        {
            JoinTestHelperWithNullAtTheEnd<GenericParameterHelper>();
        }

        public void JoinTestHelperWithNullAtTheEnd<T>()
        {
            List<string> collection = new List<string>();
            collection.Add("asd");
            collection.Add("pesho");
            collection.Add(null);

            string expected = "[asd, pesho]";
            string actual = collection.MyJoin();

            Assert.AreEqual(expected, actual);
        }
    }
}
